<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *评论管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['setmid'])){
		$params['setmid like']='%'.trim($_RQ['setmid']).'%';
		$return['params']['setmid']=$_RQ['setmid'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_kefu_comments',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['name']=pdo_getcolumn('jy_kefu_member',array('openid'=>$item['setmid'],'name'));
			//用户姓名
			$item['logo']=pdo_getcolumn('jy_kefu_member',array('openid'=>$item['setmid'],'logo'));
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'评论列表'),
		),
		'list'=>array('data'=>'list','edit'=>true,'list'=>array(
			array('name'=>'name','title'=>'客户名称','type'=>'string'),
			array('name'=>'logo','title'=>'客户头像','type'=>'image'),
			array('name'=>'msg','title'=>'评论内容','type'=>'string'),
			array('name'=>'createtime','title'=>'评论时间','type'=>'time'),
		)),
		'search_one'=>array('name'=>'setmid','add'=>false)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_kefu_comments',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}